package com.framework.model.impl;

import java.util.Arrays;
import java.util.HashMap;

import com.framework.model.IData;

@SuppressWarnings({ "unchecked", "serial" })
public class DataMap extends HashMap
implements IData{


	private String orderField = "intID";

	private String orderDirection = "ASC";
	
	
	private String callbackType;
	private String navTabId;
	private String rel;
	private String forwardUrl;
	
	
	public DataMap()
    {
    }

    public Object get(String name, Object def)
    {
        Object value = get(name);
        return value != null ? value : def;
    }

    public String[] getNames()
    {
        String names[] = (String[])keySet().toArray(new String[0]);
        Arrays.sort(names);
        return names;
    }

    public String getString(String name)
    {
        Object value = get(name);
        return value != null ? value.toString() : null;
    }

    public String getString(String name, String defaultValue)
    {
        return get(name, defaultValue).toString();
    }

    public int getInt(String name)
    {
        return getInt(name, 0);
    }

    public int getInt(String name, int defaultValue)
    {
        String value = getString(name, "");
        return "".equals(value) ? defaultValue : Integer.parseInt(value);
    }

    public double getDouble(String name)
    {
        return getDouble(name, 0.0D);
    }

    public double getDouble(String name, double defaultValue)
    {
        String value = getString(name, "");
        return "".equals(value) ? defaultValue : Double.parseDouble(value);
    }

    public boolean getBoolean(String name)
    {
        return getBoolean(name, false);
    }

    public boolean getBoolean(String name, boolean defaultValue)
    {
        String value = getString(name, "");
        return "".equals(value) ? defaultValue : Boolean.valueOf(value).booleanValue();
    }

	public String getOrderField() {
		return orderField;
	}

	public void setOrderField(String orderField) {
		this.orderField = orderField;
	}

	public String getOrderDirection() {
		return orderDirection;
	}

	public void setOrderDirection(String orderDirection) {
		this.orderDirection = orderDirection;
	}

	public String getCallbackType() {
		return callbackType;
	}

	public void setCallbackType(String callbackType) {
		this.callbackType = callbackType;
	}

	public String getNavTabId() {
		return navTabId;
	}

	public void setNavTabId(String navTabId) {
		this.navTabId = navTabId;
	}

	public String getRel() {
		return rel;
	}

	public void setRel(String rel) {
		this.rel = rel;
	}

	public String getForwardUrl() {
		return forwardUrl;
	}

	public void setForwardUrl(String forwardUrl) {
		this.forwardUrl = forwardUrl;
	}
    
}
